import Vue from 'vue'
import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/login'
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  },
  {
    path: '/home',
    name: 'Home',
    component: () => import('../views/Home.vue'),
    redirect: '/welcome',
    children:[
      {
        path: '/welcome',
        name: 'Welcome',
        component: () => import( '../views/sys/Welcome'), //系统欢迎页
      },
      {
        path: '/users',
        name: 'Users',
        component: () => import('../views/sys/Users.vue'),
      },
      {
        path: '/customer',
        name: 'Customer',
        component: () => import('../views/sys/Customer.vue'),
      },
      {
        path: '/department',
        name: 'Department',
        component: () => import('../views/sys/Department.vue'),
      },
      {
        path: '/role',
        name: 'Role',
        component: () => import('../views/sys/Role.vue'),
      },
      {
        path: '/menu',
        name: 'Menu',
        component: () => import( '../views/sys/Menu'), //系统菜单页
      },
      {
        path: '/api',
        name: 'Api',
        component: () => import( '../views/sys/Api'), //系统接口页
      },
      {
        path: '/contract',
        name: 'Contract',
        component: () => import( '../views/business/Contract'), //合同管理页
      },
      {
        path: '/conAudit',
        name: 'ConAudit',
        component: () => import( '../views/business/ConAudit'), //合同审核页
      },
      {
        path: '/addContract',
        name: 'AddContract',
        component: () => import( '../views/business/AddContract'), //合同添加页
      },
      {
        path: '/inStocks',
        name: 'InStocks',
        component: () => import( '../views/business/InStocks'), //商品入库页
      },
      {
        path: '/addInStock',
        name: 'AddInStock',
        component: () => import( '../views/business/AddInStock'), //入库添加页
      },
      {
        path: '/inAudit',
        name: 'InAudit',
        component: () => import( '../views/business/InAudit'), //入库审核页
      },
      {
        path: '/conOutStocks',
        name: 'ContractOutStocks',
        component: () => import( '../views/business/ContractOutStocks'), //合同订单页
      },
      {
        path: '/outStocks',
        name: 'OutStocks',
        component: () => import( '../views/business/OutStocks'), //商品发货页
      },
      {
        path: '/addOutStock',
        name: 'AddOutStock',
        component: () => import( '../views/business/AddOutStock'), //发货添加页
      },
      {
        path: '/outAudit',
        name: 'OutAudit',
        component: () => import( '../views/business/OutAudit'), //发货审核页
      },
      {
        path: '/goods',
        name: 'Goods',
        component: () => import( '../views/goods/Goods'), //商品列表页
      },
      {
        path: '/category',
        name: 'Category',
        component: () => import( '../views/goods/Category'), //商品分类页
      },
      {
        path: '/stocks',
        name: 'Stocks',
        component: () => import( '../views/goods/Stock'), //商品库存页
      },
      {
        path: '/self',
        name: 'Self',
        component: () => import( '../views/statistics/Self'), //个人业绩页
      },
      {
        path: '/staticGood',
        name: 'Goods',
        component: () => import( '../views/statistics/Goods'), //商品销售页
      },
      {
        path: '/swagger',
        name: 'Swagger',
        component: () => import( '../views/Swagger'), //商品库存页
      },
      {
        path: "/3001",
        component: () => import('../views/3001.vue')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
